//
//  SettingDetailHelpViewController.m
//  宜居HD
//
//  Created by 陈柏兵 on 16/5/3.
//  Copyright © 2016年 张金国. All rights reserved.
//

#import "SettingDetailHelpViewController.h"
#import "Macro.h"
#import "SettingDetailHelpViewModel.h"

@interface SettingDetailHelpViewController ()

@property (nonatomic, strong)SettingDetailHelpViewModel *settingDetailHelpViewModel;
@property (nonatomic, strong)UIWebView *currentWebView;

@end

@implementation SettingDetailHelpViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"使用帮助";
    self.view.backgroundColor = kSettingBackgroundColor;
    [self loadNetRequest];
    [self.currentWebView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
}

- (SettingDetailHelpViewModel *)settingDetailHelpViewModel {
    if (!_settingDetailHelpViewModel) {
        _settingDetailHelpViewModel = [SettingDetailHelpViewModel new];
        _settingDetailHelpViewModel.viewObject = self;
    }
    return _settingDetailHelpViewModel;
}

- (UIWebView *)currentWebView {
    if (!_currentWebView) {
        _currentWebView = [[UIWebView alloc]init];
        _currentWebView.scrollView.bounces = NO;
        _currentWebView.contentMode = UIViewContentModeScaleAspectFit;
        [_currentWebView setScalesPageToFit:YES];
        _currentWebView.clipsToBounds = YES;
        [self.view addSubview:_currentWebView];
    }
    return _currentWebView;
}

- (void)loadNetRequest {
    [self.settingDetailHelpViewModel loadRequest];
}

- (void)setHelpUrlString:(NSString *)helpUrlString {
    [_currentWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:helpUrlString]]];
}



@end
